package com.aos.erp.schools.service.index.impl;


import com.aos.erp.common.exception.BizException;
import com.aos.erp.common.utils.StringUtils;
import com.aos.erp.schools.mapper.index.IndexQueryMapper;
import com.aos.erp.schools.model.division.entity.Division;
import com.aos.erp.schools.service.division.DivisionService;
import com.aos.erp.schools.service.index.IndexQueryService;
import com.aos.erp.schools.util.UserUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * AOS驾校管理 服务实现类
 * </p>
 *
 * @author ywb
 * @since 2018-10-31
 */
@Service
public class IndexQueryServiceImpl  implements IndexQueryService {
	@Resource
	private IndexQueryMapper indexQueryMapper;
	@Resource
	private DivisionService  divisionService;

//	@Override
//	public Long studentByCityCode(String cityCode) {
//		Long count=indexQueryMapper.studentByCityCode(cityCode);
//		return null;
//	}

	@Override
	public Long selectDivisionStudent(String currentUserId) throws Exception {
		//根据当前用户获取depCode
		String depCode=UserUtil.getUserDepCode(currentUserId);
		if(!StringUtils.isNotEmpty(depCode)){
			throw new BizException("车管所数据异常");
		}
		Division division=divisionService.infoByDepCode(currentUserId);
		if(division==null){
			throw new BizException("车管所数据异常");
		}
		Long count=indexQueryMapper.studentByCityCode(division.getCityId().toString());
		return count;
	}
}











































